<!DOCTYPE HTML>
<html>
<head>
    <include file="Common:header_include"/>
    <title></title>
</head>
<body class="pos-r">
<div class="pos-a">
    <a href="javascript:void(0);" onclick="expandAll();" class="expand">全部展开</a>
    <ul id="ztree" class="ztree">
    </ul>
</div>
<div style="margin-left:220px;">
    <iframe id="iframe" frameborder="0" src="?act=getTree" style="width:100%;height:100%; display: none"></iframe>
</div>
<include file="Common:footer_include"/>
<link rel="stylesheet" href="__HUI__lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="__HUI__lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="__HUI__lib/jquery.nicescroll/jquery.nicescroll.min.js"></script>
<script type="text/javascript">
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: false,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "column_id",
                rootPId: "0"
            },
            key: {
                name: "title"
            }
        },
        async: {
            enable: true,
            url: "?act=getTree",
            autoParam: ["id"]
        },
        callback: {
            beforeClick: function (treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("ztree");
                if (treeNode.isParent) {
                    zTree.expandNode(treeNode);
                    return true;
                } else {
                    iframe.attr('src', "?act=show&id=" + treeNode.id);
                    return;
                }
            },
            onAsyncSuccess: function (event, treeId, treeNode, msg) {
                layer.close(load);
            }
        }
    };

    var iframe;
    var zNodes = [];
    var load;

    $(function () {
        $.fn.zTree.init($("#ztree"), setting, []);
        iframe = $("#iframe");
        iframe.load(function () {
            iframe.niceScroll();
            iframe.height($('.pos-r').height()-30);
        });
        load = layer.load(0, {shade: [0.8, '#fff']});
        $('.pos-a').niceScroll({
            cursorcolor: "#ccc",//#CC0071 光标颜色
            cursoropacitymax: 1, //改变不透明度非常光标处于活动状态（scrollabar“可见”状态），范围从1到0
            touchbehavior: false, //使光标拖动滚动像在台式电脑触摸设备
            cursorwidth: "5px", //像素光标的宽度
            cursorborder: "0", //     游标边框css定义
            cursorborderradius: "2px",//以像素为光标边界半径
            scrollspeed: 10,
            autohidemode: false //是否隐藏滚动条
        });
    });

    var expand = false;
    function expandAll() {
        var zTree = $.fn.zTree.getZTreeObj("ztree");
        expand = expand ? false : true;
        zTree.expandAll(expand);
        $('.expand').html(expand ? '全部折叠' : '全部展开');
    }
</script>
</body>
</html>